{{- define "main" }}
{{- $s := .Site.Params }}
{{- $p := .Params }}
{{- $scratch := newScratch }}
{{- if isset $p "image" }}
  {{- $scratch.Set "image" $p.image }}
{{- else }}
  {{ $scratch.Set "image" $s.fallBackOgImage }}
{{- end }}
{{- $image := $scratch.Get "image" }}
{{- $bg := absLangURL (path.Join "images" $image) }}
<article class="post_content">

  {{- $author := $s.Author  }}
  {{ if $author.photo }}
    <div class="author_header">
      <img src="{{ absURL $author.photo }}" alt="">
      <h2>{{  $author.name }}</h2>
    </div>
  {{- else }}
    {{- $fullAuthor := reflect.IsMap $author }}
    <h2>{{  if $fullAuthor }}{{ $author.name }}{{ else }}{{ $author }}{{ end }}</h2>
  {{- end }}
  <div class="author_intro">
    <p>「知行」- 大道至简，知易行难；道阻且长，行则将至。</p>
    <p>Charles 的个人网站，共 {{ len (where .Site.RegularPages "Section" "posts") }} 篇文章。</p>
    <p><a href="https://github.com/chaooo">Github</a>|<a href="https://gitee.com/chaoo">Gitee</a>|<a href="https://weibo.com/zhengchaooo">新浪微博</a>|<a href="mailto:chaoles@foxmail.com">chaoles@foxmail.com</a></p>
  </div>
  <div class="author_contact">

  </div>
  {{ if .Site.Params.disclaimerText }}
    <div class="author_disclaimer">
      <p><b>{{ .Site.Params.disclaimerTitle }}</b><br/>{{ .Site.Params.disclaimerText }}</p>
    </div>
  {{ end }}

  <div class="post_end">END .</div>

  <div class="post_comments">
    <div id="waline"></div>
    {{- $showComments := true }}
    {{- if eq .Site.Params.comments false }}
      {{- $showComments = false }}
    {{- else if eq .Params.comments false }}
      {{- $showComments = false }}
    {{- end }}
    {{- if ne $showComments false }}
      <script type="module">
        import { init } from 'https://unpkg.com/@waline/client@v3/dist/waline.js';
        init({
          el: '#waline', // Waline 被挂载到的元素
          serverURL: 'https://vercel.itdn.top/', // Waline 的服务端地址
          lang: 'zh-CN', // 多语言支持
          commentSorting: 'latest', // 评论列表排序方式。可选值: 'latest', 'oldest', 'hottest'
          dark: 'html[data-mode="dim"]', // 暗黑模式适配
          reaction: false, // 表情互动
        });
      </script>
    {{- end }}
  </div>

</article>
{{- end }}
